package com.flink.mybatis;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

public class UserDao {
    
    SqlSession session = ConnTool.getSession();
    
    public int insert(User user){
        int rint = session.insert("user.insertUser",user); // 第一个参数是mapper xml里的namespace+MappedStatement对应的id
        session.commit();// 不要忘记提交
        return rint;
    }

    public List<User> queryById(int id){
        List<User> list = session.selectList("user.findUserById", id); 
        return list;
    }

    public void update(User usr){
        session.update("user.updateUser", usr);
    }

    public void commit(){
        session.commit(true);
    }

    public void clearCache(){
        session.clearCache();
    }

    public void close(){
        session.close();
    }

}
